package com.ss.android.article.base.feature.detail2.video.a;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.detail.model.AdVideoInfo;
import com.ss.android.article.base.feature.feed.c.FeedDownloadAppAd;
import com.ss.android.article.base.ui.AdButtonDetailLayout;
import com.ss.android.article.browser.R;
import com.ss.android.article.common.NightModeAsyncImageView;
import com.ss.android.b.a.BaseAdsData;
import com.ss.android.common.ad.MobAdClickCombiner;

import org.json.JSONObject;

public final class a {
    public RelativeLayout b;
    public NightModeAsyncImageView c;
    public TextView d;
    public TextView e;
    public TextView f;
    public AdButtonDetailLayout g;
    public FeedDownloadAppAd h;
    Context a;
    AdVideoInfo i;
    private boolean j;
    private View.OnClickListener k;

    public a(Context arg2) {
        this.j = false;
        this.k = new b(this);
        this.a = arg2;
    }

    public final void a() {
        AppData.getInstance();
        boolean v0 = AppData.isNightMode();
        if (this.j != v0) {
            this.j = v0;
            if (this.d != null) {
                this.d.setBackgroundResource(com.ss.android.article.browser.R.drawable.cj);
                this.d.setTextColor(ContextCompat.getColor(this.a, R.color.ssxinzi12));
            }
        }
    }

    public final void a(BaseAdsData arg14, AdVideoInfo arg15) {
        FeedDownloadAppAd v12 = null;
        int v11 = View.GONE;
        if (arg15 == null) {
            this.h = v12;
            this.i = ((AdVideoInfo) null);
            UIUtils.setVisibility(this.b, v11);
            UIUtils.setOnClickListener(false, this.b, ((View.OnClickListener) null));
            return;
        }

        if (arg14 != null && ((arg14 instanceof FeedDownloadAppAd))) {
            this.h = ((FeedDownloadAppAd) arg14);
        }

        if (this.h != null && (this.h.a(this.a))) {
            try {
                JSONObject v8 = new JSONObject();
                if (!android.support.design.a.isTextEmpty(this.h.logExtra)) {
                    v8.put("log_extra", this.h.logExtra);
                }

                MobAdClickCombiner.onAdEvent(this.a, "detail_download_ad", "hide", this.h.id, 0, v8, 2);
            } catch (Exception v0) {
            }

            UIUtils.setVisibility(this.b, v11);
            UIUtils.setOnClickListener(false, this.b, ((View.OnClickListener) null));
            return;
        }

        this.i = arg15;
        UIUtils.setVisibility(this.b, 0);
        UIUtils.setOnClickListener(true, this.b, this.k);
        if (!android.support.design.a.isTextEmpty(arg15.iconUrl)) {
            this.c.setVisibility(View.VISIBLE);
            this.c.setUrl(arg15.iconUrl);
            this.d.setVisibility(v11);
        } else if (!android.support.design.a.isTextEmpty(arg15.e)) {
            this.c.setVisibility(View.INVISIBLE);
            this.d.setVisibility(View.VISIBLE);
            this.d.setText(arg15.e.substring(0, 1));
        }

        this.c.setUrl(arg15.iconUrl);
        if (!android.support.design.a.isTextEmpty(arg15.name)) {
            this.e.setText(arg15.name);
            UIUtils.setVisibility(this.e, 0);
        } else {
            UIUtils.setVisibility(this.e, v11);
        }

        if (!android.support.design.a.isTextEmpty(arg15.desc)) {
            this.f.setText(arg15.desc);
            UIUtils.setVisibility(this.f, 0);
        } else {
            UIUtils.setVisibility(this.f, v11);
        }

        if (this.h == null) {
            UIUtils.setVisibility(this.g, v11);
        } else if (this.g.a(this.h)) {
            UIUtils.setVisibility(this.g, 0);
        }

        this.a();
    }
}

